from sqlalchemy import select

from src.application.bot_settings.dto import BotSettingsDTO
from src.infrastructure.db.converters.bot_settings import convert_bot_settings_db_model_to_dto
from src.infrastructure.db.exception_mapper import exception_mapper
from src.infrastructure.db.models import BotSettings
from src.infrastructure.db.repositories.base import SQLAlchemyRepo


class BotSettingsReaderImpl(SQLAlchemyRepo):
    @exception_mapper
    async def get_bot_settings(self) -> BotSettingsDTO:
        settings: BotSettings | None = await self._session.scalar(select(BotSettings))

        return convert_bot_settings_db_model_to_dto(settings)
